package com.shiliao.app.update.dowload;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.yimei.framework.util.LogUtil;
import com.yimei.framework.util.StringUtil;

import java.io.File;


public class DowloadReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (StringUtil.isNotEmpty(action, false) && SilentConfig.CALLBACK_ACTION_NAME.equals(action)) {
            //文件下载的事件
            long fileSize = intent.getLongExtra(SilentConfig.DOWNLOAD_FILE_SIZE, -1);
            String filename = intent.getStringExtra(SilentConfig.DOWNLOAD_FILE_NAME);
            LogUtil.e("yzq", "下载文件名:" + filename);
            LogUtil.e("yzq", "下载文件大小:" + fileSize);
            if (StringUtil.isNotEmpty(action, false)) {
                File file = new File(SilentConfig.DOWNLOAD_PATH + filename);
                if (file.exists() && file.length() == fileSize) {
                    LogUtil.e("yzq", "下载成功 本地filesize:" + file.length());
                } else {
                    LogUtil.e("yzq", filename + " 本地不存在");
                }
            }
        }

    }
}
